<?php

namespace backend\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "{{%jjr_user_bank_card}}".
 *
 * @property string $id
 * @property int $jjr_user_id 经纪人ID
 * @property string $card_real_name 持卡人姓名
 * @property string $card_no 银行卡号
 * @property string $card_type 卡类型
 * @property string $bank_name 所属银行
 * @property string $bank_branch_name 支行名称
 * @property string $create_time 创建时间
 * @property string $update_time 更新时间
 * @property int $status 状态
 */
class JjrUserBankCard extends \common\core\BaseActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%jjr_user_bank_card}}';
    }

    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    # 创建之前
                    \yii\db\ActiveRecord::EVENT_BEFORE_INSERT => ['create_time', 'update_time'],
                    # 修改之前
                    \yii\db\ActiveRecord::EVENT_BEFORE_UPDATE => ['update_time']
                ],
                #设置默认值
                'value' =>date('Y-m-d H:i:s')
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['jjr_user_id', 'card_real_name', 'card_no', 'card_type', 'bank_name', 'bank_branch_name'], 'required'],
            [['jjr_user_id', 'status'], 'integer'],
            [['create_time', 'update_time'], 'safe'],
            [['card_real_name', 'card_type'], 'string', 'max' => 20],
            [['card_no'], 'string', 'max' => 255],
            [['bank_name', 'bank_branch_name'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'jjr_user_id' => '经纪人ID',
            'card_real_name' => '持卡人姓名',
            'card_no' => '银行卡号',
            'card_type' => '卡类型',
            'bank_name' => '所属银行',
            'bank_branch_name' => '支行名称',
            'create_time' => '创建时间',
            'update_time' => '更新时间',
            'status' => '状态',
        ];
    }
}
